using Microsoft.Phone.Controls.Properties;
using System;
using System.ComponentModel;
using System.Globalization;
namespace System.Windows.Controls
{
	internal static class TypeConverters
	{
		internal static bool CanConvertTo<T>(Type destinationType)
		{
			if (destinationType == null)
			{
				throw new ArgumentNullException("destinationType");
			}
			return destinationType == typeof(string) || destinationType.IsAssignableFrom(typeof(T));
		}
		internal static object ConvertTo(TypeConverter converter, object value, Type destinationType)
		{
			if (destinationType == null)
			{
				throw new ArgumentNullException("destinationType");
			}
			if (value == null && !destinationType.get_IsValueType())
			{
				return null;
			}
			if (value == null || !destinationType.IsAssignableFrom(value.GetType()))
			{
				throw new NotSupportedException(string.Format(CultureInfo.get_CurrentCulture(), Resources.TypeConverters_Convert_CannotConvert, new object[]
				{
					converter.GetType().get_Name(),
					(value != null) ? value.GetType().get_FullName() : "(null)",
					destinationType.GetType().get_Name()
				}));
			}
			return value;
		}
	}
}
